#include<bits/stdc++.h>
using namespace std;
struct fruit {
	int zi,nxt=-1;
};
int n;
fruit a[200002];
bool visit[200002];
int main() {
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%d",&a[i].zi );
		if(i-n) {
			a[i].nxt=i+1;
		} else {
			a[i].nxt =1;
		}
	}
	int ji=0,shang=-1;
	int nxet=1;
	for(int i=1; a[i].nxt!=nxet; i=nxet) {
		nxet=a[i].nxt ;
		if(shang!=-1){
			if(a[i].zi !=a[shang].zi ) {
				printf("%d ",i);
				a[shang].nxt=nxet;
				if(a[i].nxt<i) {
					printf("\n");
				}
			}else{
				shang=i;
			}
		}else{
			printf("%d ",i);
			shang=i;
		}	
	}
	return 0;
}

